From 4761641098d6eff1fadaa70f26c8c4b471b10230 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 7 Jan 2021 09:49:52 -0600 Subject: [PATCH] Add critical if widget has a parent during dispose This is a refcounting bug. Be very verbose about it instead of trying to call a function that releases a reference to the widget without references. --- gtk/gtkwidget.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 239f7735e8..6efcdccc4a 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -7187,7 +7187,13 @@ gtk_widget_dispose (GObject *object) gtk_list_list_model_clear (priv->controller_observer); if (priv->parent) - gtk_widget_unparent (widget); + { + g_critical ("%s %p has a parent %s %p during dispose. Parents hold a reference, so this should not happen.\n" + "Did you call g_object_unref() instead of gtk_widget_unparent()?", + G_OBJECT_TYPE_NAME (widget), widget, + G_OBJECT_TYPE_NAME (priv->parent), priv->parent); + priv->parent = NULL; + } while (priv->paintables) gtk_widget_paintable_set_widget (priv->paintables->data, NULL); -- 2.30.2